<?php

/**
 * 自定义钩子
 *
 */

/*
\Phpcmf\Hooks::on('cms_init', function() {
    // cms 初始化后的运行
});*/
/*\Phpcmf\Hooks::on('member_register_after', function($data) {    \Phpcmf\Service::M('member')->add_money($data['id'], 50);
	\Phpcmf\Service::M('member')->notice($data['id'], 1, '新用户注册送的50元', $url = '', $mark = '');
});*/
\Phpcmf\Hooks::on('cms_init', function() {
	$kaiguans = \Phpcmf\Service::M()->db->table('weixin')->where('name', 'config')->get()->getRowArray();
	
	$kaiguan = dr_string2array($kaiguans['denglu']);
	if ($kaiguan == 1) {
		if (IS_API_HTTP) {
			return;
		}
		if (!IS_MEMBER && APP_DIR != 'weixin' && !\Phpcmf\Service::C()->uid
			&& strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')) {
			dr_redirect(SITE_URL.'index.php?s=weixin&c=go&url='.urlencode(FC_NOW_URL));
			//dr_redirect(dr_mobile_url(FC_NOW_URL));
		}
	}
});
// 注册后赠送
/*
\Phpcmf\Hooks::on('member_register_after', function($data) {
	if (dr_is_app('scorelog')) {
		$datazs = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'kuzengsongjifen')->get()->getRowArray();
		$datas = dr_string2array($datazs['value']);
		 dr_debug('jifenkaiguan', $data['id']);
		if ($datas['jifenkaiguan']==1) {
			\Phpcmf\Service::M('member')->add_score($data['id'], $datas['zengsongjifen'], '注册赠送'.$datas['zengsongjifen'].''.SITE_SCORE, $url = '', $mark = '', $count = 0);
		}
		//\Phpcmf\Service::M('member')->add_experience($data['id'], 100, '注册送的');
		
	}
});
*/
